/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vfaq.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.vportal.portlet.vfaq.model.FAQQuestion;
import com.vportal.portlet.vfaq.model.FAQQuestionModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;

/**
 * The base model implementation for the FAQQuestion service. Represents a row in the &quot;FAQQuestion&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vfaq.model.FAQQuestionModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link FAQQuestionImpl}.
 * </p>
 *
 * @author DucNN
 * @see FAQQuestionImpl
 * @see com.vportal.portlet.vfaq.model.FAQQuestion
 * @see com.vportal.portlet.vfaq.model.FAQQuestionModel
 * @generated
 */
public class FAQQuestionModelImpl extends BaseModelImpl<FAQQuestion>
	implements FAQQuestionModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a f a q question model instance should use the {@link com.vportal.portlet.vfaq.model.FAQQuestion} interface instead.
	 */
	public static final String TABLE_NAME = "FAQQuestion";
	public static final Object[][] TABLE_COLUMNS = {
			{ "uuid_", Types.VARCHAR },
			{ "id_", Types.BIGINT },
			{ "title", Types.VARCHAR },
			{ "content", Types.VARCHAR },
			{ "language", Types.VARCHAR },
			{ "questionOrder", Types.BIGINT },
			{ "sentDate", Types.TIMESTAMP },
			{ "sentByUser", Types.VARCHAR },
			{ "senderEmail", Types.VARCHAR },
			{ "questionType", Types.VARCHAR },
			{ "modifiedByUser", Types.VARCHAR },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "hitCount", Types.BIGINT },
			{ "approved", Types.BOOLEAN },
			{ "groupId", Types.BIGINT },
			{ "userId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table FAQQuestion (uuid_ VARCHAR(75) null,id_ LONG not null primary key,title VARCHAR(300) null,content VARCHAR(2000) null,language VARCHAR(150) null,questionOrder LONG,sentDate DATE null,sentByUser VARCHAR(300) null,senderEmail VARCHAR(300) null,questionType VARCHAR(300) null,modifiedByUser VARCHAR(300) null,modifiedDate DATE null,hitCount LONG,approved BOOLEAN,groupId LONG,userId LONG)";
	public static final String TABLE_SQL_DROP = "drop table FAQQuestion";
	public static final String ORDER_BY_JPQL = " ORDER BY faqQuestion.sentDate DESC";
	public static final String ORDER_BY_SQL = " ORDER BY FAQQuestion.sentDate DESC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vfaq.model.FAQQuestion"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vfaq.model.FAQQuestion"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vfaq.model.FAQQuestion"),
			true);
	public static long APPROVED_COLUMN_BITMASK = 1L;
	public static long GROUPID_COLUMN_BITMASK = 2L;
	public static long ID_COLUMN_BITMASK = 4L;
	public static long LANGUAGE_COLUMN_BITMASK = 8L;
	public static long QUESTIONTYPE_COLUMN_BITMASK = 16L;
	public static long UUID_COLUMN_BITMASK = 32L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vfaq.model.FAQQuestion"));

	public FAQQuestionModelImpl() {
	}

	public long getPrimaryKey() {
		return _id;
	}

	public void setPrimaryKey(long primaryKey) {
		setId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_id);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return FAQQuestion.class;
	}

	public String getModelClassName() {
		return FAQQuestion.class.getName();
	}

	public String getUuid() {
		if (_uuid == null) {
			return StringPool.BLANK;
		}
		else {
			return _uuid;
		}
	}

	public void setUuid(String uuid) {
		if (_originalUuid == null) {
			_originalUuid = _uuid;
		}

		_uuid = uuid;
	}

	public String getOriginalUuid() {
		return GetterUtil.getString(_originalUuid);
	}

	public long getId() {
		return _id;
	}

	public void setId(long id) {
		_columnBitmask |= ID_COLUMN_BITMASK;

		if (!_setOriginalId) {
			_setOriginalId = true;

			_originalId = _id;
		}

		_id = id;
	}

	public long getOriginalId() {
		return _originalId;
	}

	public String getTitle() {
		if (_title == null) {
			return StringPool.BLANK;
		}
		else {
			return _title;
		}
	}

	public void setTitle(String title) {
		_title = title;
	}

	public String getContent() {
		if (_content == null) {
			return StringPool.BLANK;
		}
		else {
			return _content;
		}
	}

	public void setContent(String content) {
		_content = content;
	}

	public String getLanguage() {
		if (_language == null) {
			return StringPool.BLANK;
		}
		else {
			return _language;
		}
	}

	public void setLanguage(String language) {
		_columnBitmask |= LANGUAGE_COLUMN_BITMASK;

		if (_originalLanguage == null) {
			_originalLanguage = _language;
		}

		_language = language;
	}

	public String getOriginalLanguage() {
		return GetterUtil.getString(_originalLanguage);
	}

	public long getQuestionOrder() {
		return _questionOrder;
	}

	public void setQuestionOrder(long questionOrder) {
		_questionOrder = questionOrder;
	}

	public Date getSentDate() {
		return _sentDate;
	}

	public void setSentDate(Date sentDate) {
		_columnBitmask = -1L;

		_sentDate = sentDate;
	}

	public String getSentByUser() {
		if (_sentByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _sentByUser;
		}
	}

	public void setSentByUser(String sentByUser) {
		_sentByUser = sentByUser;
	}

	public String getSenderEmail() {
		if (_senderEmail == null) {
			return StringPool.BLANK;
		}
		else {
			return _senderEmail;
		}
	}

	public void setSenderEmail(String senderEmail) {
		_senderEmail = senderEmail;
	}

	public String getQuestionType() {
		if (_questionType == null) {
			return StringPool.BLANK;
		}
		else {
			return _questionType;
		}
	}

	public void setQuestionType(String questionType) {
		_columnBitmask |= QUESTIONTYPE_COLUMN_BITMASK;

		if (_originalQuestionType == null) {
			_originalQuestionType = _questionType;
		}

		_questionType = questionType;
	}

	public String getOriginalQuestionType() {
		return GetterUtil.getString(_originalQuestionType);
	}

	public String getModifiedByUser() {
		if (_modifiedByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _modifiedByUser;
		}
	}

	public void setModifiedByUser(String modifiedByUser) {
		_modifiedByUser = modifiedByUser;
	}

	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	public long getHitCount() {
		return _hitCount;
	}

	public void setHitCount(long hitCount) {
		_hitCount = hitCount;
	}

	public boolean getApproved() {
		return _approved;
	}

	public boolean isApproved() {
		return _approved;
	}

	public void setApproved(boolean approved) {
		_columnBitmask |= APPROVED_COLUMN_BITMASK;

		if (!_setOriginalApproved) {
			_setOriginalApproved = true;

			_originalApproved = _approved;
		}

		_approved = approved;
	}

	public boolean getOriginalApproved() {
		return _originalApproved;
	}

	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public FAQQuestion toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (FAQQuestion)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					FAQQuestion.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		FAQQuestionImpl faqQuestionImpl = new FAQQuestionImpl();

		faqQuestionImpl.setUuid(getUuid());
		faqQuestionImpl.setId(getId());
		faqQuestionImpl.setTitle(getTitle());
		faqQuestionImpl.setContent(getContent());
		faqQuestionImpl.setLanguage(getLanguage());
		faqQuestionImpl.setQuestionOrder(getQuestionOrder());
		faqQuestionImpl.setSentDate(getSentDate());
		faqQuestionImpl.setSentByUser(getSentByUser());
		faqQuestionImpl.setSenderEmail(getSenderEmail());
		faqQuestionImpl.setQuestionType(getQuestionType());
		faqQuestionImpl.setModifiedByUser(getModifiedByUser());
		faqQuestionImpl.setModifiedDate(getModifiedDate());
		faqQuestionImpl.setHitCount(getHitCount());
		faqQuestionImpl.setApproved(getApproved());
		faqQuestionImpl.setGroupId(getGroupId());
		faqQuestionImpl.setUserId(getUserId());

		faqQuestionImpl.resetOriginalValues();

		return faqQuestionImpl;
	}

	public int compareTo(FAQQuestion faqQuestion) {
		int value = 0;

		value = DateUtil.compareTo(getSentDate(), faqQuestion.getSentDate());

		value = value * -1;

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		FAQQuestion faqQuestion = null;

		try {
			faqQuestion = (FAQQuestion)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = faqQuestion.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		FAQQuestionModelImpl faqQuestionModelImpl = this;

		faqQuestionModelImpl._originalUuid = faqQuestionModelImpl._uuid;

		faqQuestionModelImpl._originalId = faqQuestionModelImpl._id;

		faqQuestionModelImpl._setOriginalId = false;

		faqQuestionModelImpl._originalLanguage = faqQuestionModelImpl._language;

		faqQuestionModelImpl._originalQuestionType = faqQuestionModelImpl._questionType;

		faqQuestionModelImpl._originalApproved = faqQuestionModelImpl._approved;

		faqQuestionModelImpl._setOriginalApproved = false;

		faqQuestionModelImpl._originalGroupId = faqQuestionModelImpl._groupId;

		faqQuestionModelImpl._setOriginalGroupId = false;

		faqQuestionModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<FAQQuestion> toCacheModel() {
		FAQQuestionCacheModel faqQuestionCacheModel = new FAQQuestionCacheModel();

		faqQuestionCacheModel.uuid = getUuid();

		String uuid = faqQuestionCacheModel.uuid;

		if ((uuid != null) && (uuid.length() == 0)) {
			faqQuestionCacheModel.uuid = null;
		}

		faqQuestionCacheModel.id = getId();

		faqQuestionCacheModel.title = getTitle();

		String title = faqQuestionCacheModel.title;

		if ((title != null) && (title.length() == 0)) {
			faqQuestionCacheModel.title = null;
		}

		faqQuestionCacheModel.content = getContent();

		String content = faqQuestionCacheModel.content;

		if ((content != null) && (content.length() == 0)) {
			faqQuestionCacheModel.content = null;
		}

		faqQuestionCacheModel.language = getLanguage();

		String language = faqQuestionCacheModel.language;

		if ((language != null) && (language.length() == 0)) {
			faqQuestionCacheModel.language = null;
		}

		faqQuestionCacheModel.questionOrder = getQuestionOrder();

		Date sentDate = getSentDate();

		if (sentDate != null) {
			faqQuestionCacheModel.sentDate = sentDate.getTime();
		}
		else {
			faqQuestionCacheModel.sentDate = Long.MIN_VALUE;
		}

		faqQuestionCacheModel.sentByUser = getSentByUser();

		String sentByUser = faqQuestionCacheModel.sentByUser;

		if ((sentByUser != null) && (sentByUser.length() == 0)) {
			faqQuestionCacheModel.sentByUser = null;
		}

		faqQuestionCacheModel.senderEmail = getSenderEmail();

		String senderEmail = faqQuestionCacheModel.senderEmail;

		if ((senderEmail != null) && (senderEmail.length() == 0)) {
			faqQuestionCacheModel.senderEmail = null;
		}

		faqQuestionCacheModel.questionType = getQuestionType();

		String questionType = faqQuestionCacheModel.questionType;

		if ((questionType != null) && (questionType.length() == 0)) {
			faqQuestionCacheModel.questionType = null;
		}

		faqQuestionCacheModel.modifiedByUser = getModifiedByUser();

		String modifiedByUser = faqQuestionCacheModel.modifiedByUser;

		if ((modifiedByUser != null) && (modifiedByUser.length() == 0)) {
			faqQuestionCacheModel.modifiedByUser = null;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			faqQuestionCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			faqQuestionCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		faqQuestionCacheModel.hitCount = getHitCount();

		faqQuestionCacheModel.approved = getApproved();

		faqQuestionCacheModel.groupId = getGroupId();

		faqQuestionCacheModel.userId = getUserId();

		return faqQuestionCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(33);

		sb.append("{uuid=");
		sb.append(getUuid());
		sb.append(", id=");
		sb.append(getId());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", content=");
		sb.append(getContent());
		sb.append(", language=");
		sb.append(getLanguage());
		sb.append(", questionOrder=");
		sb.append(getQuestionOrder());
		sb.append(", sentDate=");
		sb.append(getSentDate());
		sb.append(", sentByUser=");
		sb.append(getSentByUser());
		sb.append(", senderEmail=");
		sb.append(getSenderEmail());
		sb.append(", questionType=");
		sb.append(getQuestionType());
		sb.append(", modifiedByUser=");
		sb.append(getModifiedByUser());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", hitCount=");
		sb.append(getHitCount());
		sb.append(", approved=");
		sb.append(getApproved());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(52);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vfaq.model.FAQQuestion");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>uuid</column-name><column-value><![CDATA[");
		sb.append(getUuid());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>id</column-name><column-value><![CDATA[");
		sb.append(getId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>content</column-name><column-value><![CDATA[");
		sb.append(getContent());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>language</column-name><column-value><![CDATA[");
		sb.append(getLanguage());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>questionOrder</column-name><column-value><![CDATA[");
		sb.append(getQuestionOrder());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>sentDate</column-name><column-value><![CDATA[");
		sb.append(getSentDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>sentByUser</column-name><column-value><![CDATA[");
		sb.append(getSentByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>senderEmail</column-name><column-value><![CDATA[");
		sb.append(getSenderEmail());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>questionType</column-name><column-value><![CDATA[");
		sb.append(getQuestionType());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedByUser</column-name><column-value><![CDATA[");
		sb.append(getModifiedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>hitCount</column-name><column-value><![CDATA[");
		sb.append(getHitCount());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>approved</column-name><column-value><![CDATA[");
		sb.append(getApproved());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = FAQQuestion.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			FAQQuestion.class
		};
	private String _uuid;
	private String _originalUuid;
	private long _id;
	private long _originalId;
	private boolean _setOriginalId;
	private String _title;
	private String _content;
	private String _language;
	private String _originalLanguage;
	private long _questionOrder;
	private Date _sentDate;
	private String _sentByUser;
	private String _senderEmail;
	private String _questionType;
	private String _originalQuestionType;
	private String _modifiedByUser;
	private Date _modifiedDate;
	private long _hitCount;
	private boolean _approved;
	private boolean _originalApproved;
	private boolean _setOriginalApproved;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _userId;
	private String _userUuid;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private FAQQuestion _escapedModelProxy;
}